package com.test.p19memento.example01;

/**
 * 源发器类
 */
public class Emp {

    private String name;

    private int age ;

    private double salary;


    public Emp(String name, int age, double salarry) {
        this.name = name;
        this.age = age;
        this.salary = salarry;
    }

    /**
     * 进行备忘操作，并返回备忘对象
     * @return
     */
    public EmpMemento memento(){
        return new EmpMemento(this);
    }


    public void recover(EmpMemento mmt){
        this.age = mmt.getAge();
        this.name = mmt.getName();
        this.salary = mmt.getSalary();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Emp{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", salary=" + salary +
                '}';
    }
}
